/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('superappnlp', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model NlpAddressNormalizationRequest {
  cityStdManual?: string(name='CityStdManual'),
  cityStr?: string(name='CityStr', example='BACOLOR'),
  clientToken?: string(name='ClientToken'),
  districtStdManual?: string(name='DistrictStdManual'),
  instanceId?: string(name='InstanceId', example='10671'),
  provinceStdManual?: string(name='ProvinceStdManual'),
  provinceStr?: string(name='ProvinceStr', example='PAMPANGA'),
  queryStr?: string(name='QueryStr', example='350 Magliman, Bacolor, Pampanga AQUA MALTA Refilling Station'),
}

model NlpAddressNormalizationResponseBody = {
  code?: string(name='Code'),
  data?: {
    cityStd?: string(name='CityStd'),
    districtStd?: string(name='DistrictStd'),
    provinceStd?: string(name='ProvinceStd'),
    results?: [ string ](name='Results'),
    statusEs?: string(name='StatusEs'),
  }(name='Data'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='99540D1A-9112-56E5-8DCC-1A2603F4C500'),
  result?: string(name='Result', example='success'),
  success?: boolean(name='Success', example='true'),
  timestamp?: string(name='Timestamp', example='1701051540592'),
}

model NlpAddressNormalizationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: NlpAddressNormalizationResponseBody(name='body'),
}

/**
 * @summary 地址解析
 *
 * @param request NlpAddressNormalizationRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return NlpAddressNormalizationResponse
 */
async function nlpAddressNormalizationWithOptions(request: NlpAddressNormalizationRequest, runtime: Util.RuntimeOptions): NlpAddressNormalizationResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.cityStdManual)) {
    query['CityStdManual'] = request.cityStdManual;
  }
  if (!Util.isUnset(request.cityStr)) {
    query['CityStr'] = request.cityStr;
  }
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.districtStdManual)) {
    query['DistrictStdManual'] = request.districtStdManual;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.provinceStdManual)) {
    query['ProvinceStdManual'] = request.provinceStdManual;
  }
  if (!Util.isUnset(request.provinceStr)) {
    query['ProvinceStr'] = request.provinceStr;
  }
  if (!Util.isUnset(request.queryStr)) {
    query['QueryStr'] = request.queryStr;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'NlpAddressNormalization',
    version = '2024-09-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 地址解析
 *
 * @param request NlpAddressNormalizationRequest
 * @return NlpAddressNormalizationResponse
 */
async function nlpAddressNormalization(request: NlpAddressNormalizationRequest): NlpAddressNormalizationResponse {
  var runtime = new Util.RuntimeOptions{};
  return nlpAddressNormalizationWithOptions(request, runtime);
}

